package cn.javase.base.io._01_File相关的流;

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderTest {

    /* 读取文本 */
    @Test
    public void testReadFile() throws FileNotFoundException {
        try(FileReader fileReader = new FileReader("D:\\Code\\study\\JavaCode\\JavaSEDemo\\base\\src\\main\\java\\cn\\javase\\base\\io\\_01_File相关的流\\汉字.txt")) {
            char[] chars = new char[2];
            int len;
            while ((len = fileReader.read(chars)) != -1) {
                System.out.print(new String(chars, 0, len));
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }

}
